<extend name="Layout/base" />
<block name="css">
	<style>
		.el-main {
			padding: 0 20px;
			border: 1px solid #ccc;
			height: 100%;
		}
		.el-form {
			background: #fff;
			margin-top: 20px;
			padding-bottom: 20px;
		}
		.project {
			display: flex;
			border-bottom: 1px solid #ccc;
			padding-top: 20px;
		}
		.loginfo {
			display: flex;
			padding-top: 20px;
		}
		.title {
			font-size: 20px;
			margin-left: 20px;
		}
		.vertify {
			display: flex;
		}
		.getcode {
			height: 30px;
			line-height: 30px;
			border: 1px solid #ccc;
			margin-left: 20px;
			padding: 0 10px;
			border-radius: 4px;
		}
		.select {
			margin-left: 30px;
			margin-bottom: 20px;
		}
		.btns {
			margin-top: 60px;
			display: flex;
			justify-content: space-between;
		}
	</style>
</block>
<block name="content">
	<el-form ref="form" label-width="110px">
		<div class="project">
			<div class="title">账号类型</div>
			<div class="select">
				<el-select v-model="param.status" placeholder="请选择">
					<el-option label="超级管理员" value="1"></el-option>
					<el-option label="项目负责人" value="3"></el-option>
					<el-option label="财务人员" value="2"></el-option>
				</el-select>
			</div>
		</div>
		<div class="loginfo">
			<div class="title">登录信息</div>
			<div>
				<el-form-item label="昵称">
					<el-input v-model="param.nickname" placeholder="请输入"></el-input>
				</el-form-item>
				<el-form-item label="账号">
					<el-input v-model="param.username" placeholder="请输入"></el-input>
				</el-form-item>
				<!-- <div class="vertify">
                    <el-form-item label="验证码">
                        <el-input v-model="form.vercode" placeholder="请输入"></el-input>
                    </el-form-item>
                    <div class="getcode">获取验证码</div>
                </div> -->
				<el-form-item label="登录密码">
					<el-input v-model="param.password" show-password placeholder="请输入"></el-input>
				</el-form-item>
			</div>
		</div>
		<div class="btns">
			<el-form-item>
				<el-button type="primary" @click="edit">保存修改</el-button>
				<el-button @click="reback">取消</el-button>
			</el-form-item>
			<el-button @click="deleteById" type="danger" style="height:40px;margin-right:40px;"><i class="el-icon-delete"></i>删除</el-button>
		</div>
	</el-form>
</block>
<block name="js">
	<script>
        new Vue({
            el: '#app',
            data: function() {
                return {
                    param:{
                        id: "{$id}"
                    }
                }
            },
            created: function () {
				this.getUserById();
            },
            methods: {
                getUserById: function () {
                    var _this = this;
                    $.post(HOME_URL + '/orderAdmin/Admin/getUserById', _this.param, function (data) {
                        if(data.status){
                            _this.param = data.data;
                            _this.param.password = '';
                        }else{
                            _this.$message.error(data.msg);
                        }
                    }, 'json');
                },
                edit() {
                    var _this = this;
                    $.post(HOME_URL + '/orderAdmin/Admin/editById', _this.param, function (data) {
                        if(data.status){
                            _this.$message({
                                type: 'success',
                                message: '修改成功'
                            });
                        }else{
                            _this.$message.error(data.msg);
                        }
                    }, 'json');
                },
                deleteById: function () {
                    var _this = this;
                    $.post(HOME_URL + '/orderAdmin/Admin/delete', _this.param, function (data) {
                        if(data.status){
                            _this.$message({
                                type: 'success',
                                message: '删除成功'
                            });
                            setTimeout(function () {
								location.href = HOME_URL + "/orderAdmin/Admin/index";
                            }, 1000);
                        }else{
                            _this.$message.error('删除失败');
                        }
                    }, 'json');
                },
                reback: function () {
					history.go(-1);
                }
            }
        });
	</script>
</block>